<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserVerify extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|unique:App\Models\Users\Users,name',
            'tel' => 'required|numeric',
            'birth' => 'required|date',
            'idcard' => 'required|unique:App\Models\Users\Users,idcard',
            'addr' => 'required|string',
            'password' => 'required|alpha_dash',
            'grade' => 'required|numeric',
            'group' => 'required|numeric',
        ];
    }

    public function messages()
    {
        return [
            'name.required' => '用户名称必须填写',
            'name.unique' => '用户名称已存在',
            'tel.required' => '手机号必须填写',
            'tel.numeric' => '手机号格式错误',
            'birth.required' => '用户生日必须填写',
            'birth.date' => '用户生日格式错误',
            'idcard.required' => '用户身份证必须填写',
            'idcard.unique' => '该证件信息已被使用',
            'addr.required' => '用户地址必须填写',
            'addr.string' => '用户地址格式错误',
            'password.required' => '用户密码必须填写',
            'password.alpha_dash' => '密码填写格式错误',
            'grade.required' => '用户等级必须选择',
            'grade.numeric' => '用户等级错误传递',
            'group.required' => '用户分组必须选择',
            'group.numeric' => '用户分组错误传递',
        ];
    }
}
